package com.then.architecture.di;

import android.app.Application;

import com.luojilab.componentservice.GlobalEventManager;

import javax.inject.Inject;

import dagger.android.HasActivityInjector;
import timber.log.Timber;

/**
 * Created by 42524 on 2018/1/12.
 */

public class DaggerDelegate {

    @Inject
    DaggerActivityLifecycleCallbacks mActivityLifecycleCallbacks;

    private DaggerComponent mComponent;

    private final Application mApplication;

    public DaggerDelegate(Application application) {
        mApplication = application;

    }

    public void onCreate() {
        Timber.plant(new Timber.DebugTree());
        mComponent = DaggerDaggerComponent.builder()
                .daggerModule(new DaggerModule(mApplication))
                .build();
        mComponent.inject(this);

        mApplication.registerActivityLifecycleCallbacks(mActivityLifecycleCallbacks);
    }


    public DaggerComponent getComponent() {
        return mComponent;
    }
}
